<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Migrations\Migration;

return new class extends Migration {
    
    protected $connection = "default";

    public function up(): void
    {
        \support\Db::schema()->create('system_config',function (Blueprint $table){
            $table->increments('id');
            $table->string("lable")->comment("配置名称");
            $table->string("item")->comment("配置项");
            $table->string("value")->comment("配置值");
            $table->string("type")->comment("配置值类型：bool,int,string,float");
            $table->string("description")->comment("描述");

            $table->softDeletes();
            $table->timestamps();

            $table->comment("系统配置表");
        });

        \support\Db::schema()->create('system_dict',function (Blueprint $table){
            $table->increments('id');

            $table->string("item")->comment("索引项");
            $table->string("code")->comment("索引代码");
            $table->tinyInteger("state")->default(1)->comment("状态：-1停用，1启用");
            $table->string("description")->comment("描述");

            $table->timestamps();
            $table->softDeletes();
            $table->comment("字典表");
        });

        \support\Db::schema()->create('system_dict_data',function (Blueprint $table){
            $table->increments('id');

            $table->integer("dict_id")->unsigned()->comment("字典表id");
            $table->string("label")->comment("标签");
            $table->string("value")->comment("字典值");
            $table->tinyInteger("state")->default(1)->comment("状态：-1停用，1启用");
            $table->tinyInteger("sort")->default(0)->comment("排序");

            $table->timestamps();
            $table->softDeletes();
            $table->comment("字典数据表");
        });
    }

    public function down(): void
    {
        \support\Db::schema()->dropIfExists('system_config');
        \support\Db::schema()->dropIfExists('system_dict');
        \support\Db::schema()->dropIfExists('system_dict_data');
    }
};